import { authedApi } from '../utils/axios';

// 获取数据集列表 validateTaskTitle
export async function getDatasetList(project_id, params = {}) {
  return authedApi.get(`v2/projects/${project_id}/datasets/`, { params });
}

//获取某种类型的数据集
export function typeOfDataset(project_id, params = {}) {
  return authedApi.get(`v2/projects/${project_id}/datasets/type_of_dataset/`, {
    params,
  });
}

//获取数据集版本不分页
export function getVersion(project_id, version_id) {
  return authedApi.get(
    `v2/projects/${project_id}/datasets/${version_id}/version/get_versions/`
  );
}

//验证数据集是否重复

//验证数据集标题是否存在
export function validateDatasetListTitle(project_id, params = {}) {
  return authedApi.post(`v2/projects/${project_id}/datasets/validate/`, params)
}

//验证数据标注任务名称是否重复 validateTaskTitle
export function validateTaskTitle(project_id, params = {}) {
  return authedApi.post(`v2/projects/${project_id}/data_annotation/validate_title/`, params);
}

//编辑
export function handleEditor(project_id,dataset_id,version_id, params = {}) {
  return authedApi.put(`v2/projects/${project_id}/datasets/${dataset_id}/version/${version_id}/edit/`, params)
}

//删除数据集版本
export function deleteDatasetListData(project_id,dataset_id,version_id, params = {}) {
  return authedApi.post(`v2/projects/${project_id}/datasets/${dataset_id}/version/${version_id}/delete_data/`, params)
}
//创建数据集 start
export function createModelData(project_id, params = {}) {
  return authedApi.post(`v2/projects/${project_id}/datasets/`, params);
}

//创建数据集 end

//获取数据集类型
export function getDatasetType() {
  return authedApi.get(`v2/dataset_type/`);
}

//合并数据集
export function mergeDatasetsFun(project_id,params={}) {
  return authedApi.post(`v2/projects/${project_id}/datasets/merge/`,params)
}

// 删除数据集 start
export function deleteModelData(project_id, dataset_id) {
  return authedApi.delete(`v2/projects/${project_id}/datasets/${dataset_id}/`);
}

//删除数据集 end

// 获取数据集详情
export function getDatasetDetail(project_id, dataset_id, params = {}) {
  return authedApi.get(`v2/projects/${project_id}/datasets/${dataset_id}/`);
}

// 获取数据集版本文件
export function getDatasetDetailVersions(project_id, dataset_id,version_id,params={}) {
  return authedApi.get(`v2/projects/${project_id}/datasets/${dataset_id}/version/${version_id}/data/`,{params});
}
// 修改数据集详情
export function updateDataset(project_id, dataset_id, params = {}) {
  return authedApi.put(`/projects/${project_id}/datasets/${dataset_id}/`, params);
}

// 数据集标注详情
export function getDatasetDataList(project_id, dataset_id,params = {}) {
  return authedApi.get(`v2/projects/${project_id}/data_annotation/${dataset_id}/`, {params});
}

// 数据集标注详情里面的分页接口
export function getDataList(project_id, dataset_id, params = {}) {
  return authedApi.get(`v2/projects/${project_id}/annotation/${dataset_id}/label/`, {params});
}

export function uploadDatasetData(project_id, dataset_id, params = {}) {
  return authedApi.post(`/projects/${project_id}/datasets/${dataset_id}/data/`, params);
}

// 向数据集添加数据
export function batchUploadDatasetData(project_id, dataset_id, params = {}) {
  return authedApi.post(`/projects/${project_id}/datasets/${dataset_id}/data/batch_import/`, params);
}

export function getDatasetDataDetail(project_id, dataset_id, data_id, params = {}) {
  return authedApi.get(`/projects/${project_id}/datasets/${dataset_id}/data/${data_id}/`, params);
}

export function deleteDatasetData(project_id, dataset_id, data_id) {
  return authedApi.delete(`/projects/${project_id}/datasets/${dataset_id}/data/${data_id}/`);
}

// 更新标注信息
export function updateDataAnnotation(project_id, dataset_id, data_id, params = {}) {
  return authedApi.post(`v2/projects/${project_id}/annotation/${dataset_id}/label/${data_id}/make_note/`, params);
}

export function getDatasetFeaturesetList(project_id, dataset_id, params = {}) {
  return authedApi.get(`/projects/${project_id}/datasets/${dataset_id}/featuresets/`, params);
}

export function createDatasetFeatureset(project_id, dataset_id, params = {}) {
  return authedApi.post(`/projects/${project_id}/datasets/${dataset_id}/generate_featureset/`, params);
}

export function getDatasetFeatureset(project_id, dataset_id, featrueset_id) {
  return authedApi.get(`/projects/${project_id}/datasets/${dataset_id}/featuresets/${featrueset_id}/`);
}

export function updateDatasetFeatureset(project_id, dataset_id, featrueset_id, params = {}) {
  return authedApi.put(`/projects/${project_id}/datasets/${dataset_id}/featuresets/${featrueset_id}/`, params);
}

export function deleteDatasetFeatureset(project_id, dataset_id, featrueset_id) {
  return authedApi.delete(`/projects/${project_id}/datasets/${dataset_id}/featuresets/${featrueset_id}/`);
}

// 发布数据集版本
export function createVersion(project_id,dataset_id, params = {}) {
  return authedApi.post(`/projects/${project_id}/datasets/${dataset_id}/version/`, params);
}

// 删除版本信息
export function deleteVeersionData(project_id, dataset_id, version_id) {
  return authedApi.delete(`v2/projects/${project_id}/datasets/${dataset_id}/version/${version_id}/`);
}

//导入数据集
export function importData(project_id,dataset_id,version_id, params = {}) {
  return authedApi.post(`v2/projects/${project_id}/datasets/${dataset_id}/version/${version_id}/import_data/`, params);
}
// export function importData(project_id,version_id, params = {}) {
//   return authedApi.post(`v2/projects/${project_id}/datasets/version/${version_id}/import_data/`, params);
// }


// 导出数据集版本
export function exportDataSet(project_id,dataset_id,version_id,params={}) {
  return authedApi.get(`v2/projects/${project_id}/datasets/${dataset_id}/version/${version_id}/export/`, {params});
}
//分享数据集版本
export function shartDataSet(project_id,dataset_id,version_id) {
  return authedApi.get(`v2/projects/${project_id}/datasets/${dataset_id}/version/${version_id}/share/`);
}

// 数据集详情导入历史
export function importHistory(project_id,dataset_id,params={}) {
  return authedApi.get(`/projects/${project_id}/datasets/${dataset_id}/import_history/`,{params});
}
// 获取数据集版本 start
export function versionManage(project_id,dataset_id,params={}) {
  return authedApi.get(`v2/projects/${project_id}/datasets/${dataset_id}/version/`,{params});
}

//发布数据集版本
export function resoveVersion(project_id,dataset_id,version_id, params = {}) {
  return authedApi.post(`v2/projects/${project_id}/datasets/${dataset_id}/version/${version_id}/resolve/`, params);
}

//取消发布数据集版本
export function cancleResoveVersion(project_id,dataset_id,version_id, params = {}) {
  return authedApi.post(`v2/projects/${project_id}/datasets/${dataset_id}/version/${version_id}/resolve/`, params);
}
//获取单个数据集版本的版本文件
export function getDataFileFromVersion(project_id,dataset_id,version_id,params={}) {
  return authedApi.get(`/v2/projects/${project_id}/datasets/${dataset_id}/version/${version_id}/data/`,{params});
}



// 创建标注任务 start
export function dataLabel(project_id,params={}) {
  return authedApi.post(`v2/projects/${project_id}/data_annotation/`,params);
}
// 创建标注任务 end


//搜索标注任务 start
export function searchDataLabel(project_id,params={}) {
  return authedApi.get(`v2/projects/${project_id}/data_annotation/`,{params});
}


//获取数据的标注任务 start
export function getdataLabel(project_id,params={}) {
  return authedApi.get(`v2/projects/${project_id}/data_annotation/`,{params});
}
export function getTasksLabeled(project_id,params={}) {
  return authedApi.get(`v2/projects/${project_id}/data_annotation/tasks_labeled/`,{params});
}
//获取数据的标注任务 end

//获取单个数据集版本下的标注任务 start
export function getDatasetsAnnotation(project_id,params={}) {
  return authedApi.get(`v2/projects/${project_id}/data_annotation/`, {params});
}
//获取单个数据集版本下的标注任务 end

//获取地址下的内容

export function getTextContent(url) {
  return authedApi.get(url);
}
export function getTextContentInfo(url) {
  return authedApi.get(url);
}
// 删除数据标注任务 start
export function deletedataLabel(project_id,dataset_id) {
  return authedApi.delete(`v2/projects/${project_id}/data_annotation/${dataset_id}/`);
}
// 删除数据标注任务 end
// 删除标注数据
export function deleteOneLabel(project_id,dataset_id,label_task_id) {
  return authedApi.delete(`/projects/${project_id}/datasets/${dataset_id}/data/${label_task_id}/`);
}
// 标注任务详情
export function dataLabelDetail(project_id,label_task_id) {
  return authedApi.get(`/projects/${project_id}/data_label/${label_task_id}/`);
}
//标注页添加标签
export function setLabelData(project_id,label_task_id,parmas={}) {
  return authedApi.patch(`v2/projects/${project_id}/data_annotation/${label_task_id}/`,parmas);
}
// 搜索标签
export function searchLabel(project_id,label_task_id,params={}) {
  return authedApi.get(`v2/projects/${project_id}/data_annotation/${label_task_id}/search_label/`, {params});
}



//批量删除标注数据/清空标注内容
export function setAllData(project_id,label_task_id, parmas={}) {
  return authedApi.delete(`v2/projects/${project_id}/annotation/${label_task_id}/label/batch_delete/`,{data:parmas});
}
// 获取特征库列表
export function getFeatureset(project_id,params={}) {
  return authedApi.get(`v2/projects/${project_id}/feature_set/`,{params});
}
// 新增加特征库
export function addFeatureset(project_id, parmas={}) {
  return authedApi.post(`v2/projects/${project_id}/feature_set/`,parmas);
}
// 获取导出数据格式
export function getExportFormat(project_id,label_task_id, parmas={}) {
  return authedApi.get(`v2/projects/${project_id}/data_annotation/${label_task_id}/export_format/`,parmas);
}
//删除特征库
export function deleteFeatureset(project_id,featureset_id,parmas={}) {
  return authedApi.delete(`v2/projects/${project_id}/feature_set/${featureset_id}/`,parmas);
}
//修改特征库数据
export function setFeatureset(project_id,featureset_id,parmas={}) {
  return authedApi.put(`v2/projects/${project_id}/feature_set/${featureset_id}/`,parmas);
}
//特征集合拆分
export function featureSplitData(project_id,featureset_id,parmas={}) {
  return authedApi.put(`v2/projects/${project_id}/feature_set/${featureset_id}/split_data/`,parmas);
}
//获取特征集详情
export function getFeatureDetail(project_id,featureset_id, parmas={}) {
  return authedApi.get(`v2/projects/${project_id}/feature_set/${featureset_id}/`,parmas);
}
//特征库训练数据和验证数据查询
export function getSetData(project_id,featureset_id, params = {}) {
  return authedApi.get(`v2/projects/${project_id}/feature_set/${featureset_id}/data/`,{params});
}
//特征库数据下载
export function downloadFeatureset(project_id,featureset_id) {
  return authedApi.get(`v2/projects/${project_id}/feature_set/${featureset_id}/export/`,{
    responseType: 'blob'
  })
}
export function validateFeaturesetName(project_id, params = {}) {
  return authedApi.post(`v2/projects/${project_id}/feature_set/validate_title/`,params)
}
//数据标注--获取所有标注类型


//数据处理
//获取算法id、getProcessAlgorithmId
export function getProcessAlgorithmIdHandle(project_id, params = {}) {
  return authedApi.post(`v2/projects/${project_id}/process/algorithm_id/`,params)
}
//获取超参数
export function getMlParametersHandle(project_id, params = {}) {
  return authedApi.post(`v2/projects/${project_id}/process/ml_parameters/`,params)
}
//创建数据处理任务
export function createProcess(project_id, params = {}) {
  return authedApi.post(`v2/projects/${project_id}/process/`,params)
}
//获取数据处理列表数据
export function getProcessList(project_id, params = {}) {
  return authedApi.get(`v2/projects/${project_id}/process/`,{params});
}
//删除数据处理
export function getDeleteTask(project_id,task_id, params = {}) {
  return authedApi.delete(`v2/projects/${project_id}/process/${task_id}/`,{params});
}
//验证标题接口validateDatasetListTitle
export function validateProcessTitle(project_id, params = {}) {
  return authedApi.post(`v2/projects/${project_id}/process/validate/`,params)
}
